var array1 = [1, 2, '1', 2, 1]
var array2 = [1, 1, '1', 2, 2]
var array3 = [1, 1, 'a', 'A', 2, 2]

function unique(array, isSorted, iteratee) {
  var res = []
  var seen = []

  for (var i = 0, len = array.length; i < len; i++) {
    var value = array[i]
    var computed = iteratee ? iteratee(value, i, array) : value

    if (isSorted) {
      if (seen !== value) {
        res.push(value)
      }
      seen = value
    } 
    else if (iteratee) {
      if (seen.indexOf(computed) === -1) {
        seen.push(computed)
        res.push(value)
      }
    } 
    else if (res.indexOf(value) === -1) {
      res.push(value)
    }
  }
  return res
}

let newArr = unique(array3, false, function(item, index, arrqy3) {
  return typeof item == 'string' ? item.toLowerCase() : item
})

console.log(newArr);